package guijavacommander.actions;

import guijavacommander.FilePanel;

import javax.swing.*;
import java.awt.event.ActionEvent;
import java.io.File;
import java.io.IOException;
import java.io.DataInput;
import java.io.DataInputStream;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

/**
 * User: Deady
* Date: 17.07.2009
* Time: 10:38:59
*/
public class OpenFileAction extends AbstractAction {
    private final FilePanel l;
    private Log logger = LogFactory.getLog(OpenFileAction.class);

    public OpenFileAction(FilePanel l) {
        this.l = l;
    }

    public void actionPerformed(ActionEvent e) {
        File f = l.getCurrentFile();
        if (f.isFile()) {
            logger.debug("Opening file: "+f);

            try{
                Runtime.getRuntime().exec(new String[] {
                        "gnome-open",
                        f.getAbsolutePath()
                });
            }
            catch (Exception ex){
                ex.printStackTrace();
            }


        }
    }



}
